// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "CommonActivatableWidget.h"
#include "Widgets/IGameSettingActionInterface.h"

#include "LyraSafeZoneEditor.generated.h"

enum class ECommonInputType : uint8;

class UCommonButtonBase;
class UCommonRichTextBlock;
class UGameSetting;
class UGameSettingValueScalar;
class UObject;
class UWidgetSwitcher;
struct FAnalogInputEvent;
struct FFrame;
struct FGameplayTag;
struct FGeometry;
struct FPointerEvent;

UCLASS(Abstract)
class ULyraSafeZoneEditor : public UCommonActivatableWidget, public IGameSettingActionInterface
{
	GENERATED_BODY()

public:
	FSimpleMulticastDelegate OnSafeZoneSet; // 安全区域设置委托
	
public:
	ULyraSafeZoneEditor(const FObjectInitializer& Initializer);

	/**
	 * 为设置执行操作的实现
	 * @param ActionTag 操作标签
	 * @param InSetting 游戏设置
	 * @return 是否成功执行
	 */
	virtual bool ExecuteActionForSetting_Implementation(FGameplayTag ActionTag, UGameSetting* InSetting) override;

protected:

	UPROPERTY(EditAnywhere, Category = "Restrictions")
	bool bCanCancel = true; // 是否可以取消

	/**
	 * 当控件激活时的原生处理
	 */
	virtual void NativeOnActivated() override;
	/**
	 * 当控件初始化时的原生处理
	 */
	virtual void NativeOnInitialized() override;
	/**
	 * 当模拟值改变时的原生处理
	 * @param InGeometry 几何信息
	 * @param InAnalogEvent 模拟输入事件
	 * @return 回复处理
	 */
	virtual FReply NativeOnAnalogValueChanged(const FGeometry& InGeometry, const FAnalogInputEvent& InAnalogEvent) override;
	/**
	 * 当鼠标滚轮滚动时的原生处理
	 * @param InGeometry 几何信息
	 * @param InMouseEvent 鼠标事件
	 * @return 回复处理
	 */
	virtual FReply NativeOnMouseWheel(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent) override;
	
	/**
	 * 处理输入模式改变
	 * @param InInputType 输入类型
	 */
	void HandleInputModeChanged(ECommonInputType InInputType);

private:
	/**
	 * 处理返回按钮点击
	 */
	UFUNCTION()
	void HandleBackClicked();

	/**
	 * 处理完成按钮点击
	 */
	UFUNCTION()
	void HandleDoneClicked();

	TWeakObjectPtr<UGameSettingValueScalar> ValueSetting; // 标量值设置弱引用

	UPROPERTY(BlueprintReadOnly, meta = (BindWidget, AllowPrivateAccess = true))
	TObjectPtr<UWidgetSwitcher> Switcher_SafeZoneMessage; // 安全区域消息切换器

	UPROPERTY(BlueprintReadOnly, meta = (BindWidget, AllowPrivateAccess = true))
	TObjectPtr<UCommonRichTextBlock> RichText_Default; // 默认富文本

	UPROPERTY(BlueprintReadOnly, meta = (BindWidget, AllowPrivateAccess = true))
	TObjectPtr<UCommonButtonBase> Button_Back; // 返回按钮

	UPROPERTY(BlueprintReadOnly, meta = (BindWidget, AllowPrivateAccess = true))
	TObjectPtr<UCommonButtonBase> Button_Done; // 完成按钮
};